<?php 
	echo $this->Form->create(false, array(
		'class' => 'form-inline',
		'type' => 'get',  
		'inputDefaults' => array(
			'label' => false,
			'div' => false,
		)
	));
?>
	<?php 
		$queryString = $this->params['url'];
		unset($queryString['url']);
		$this->Paginator->options(array('url' => array('?' => $queryString)));
	?>
	<?php echo $this->Form->input('conditions[keyword]', array(
			'placeholder' => 'Search Name, UserName, Email...',
			'value' => !empty($queryString['conditions']['keyword']) ? $queryString['conditions']['keyword'] : ''
	));?>
	&nbsp;
	<label class="radio inline">
		<input 
			type="radio" 
			name="conditions[showTrash]" 
			value="0"
			<?php echo (empty($queryString['conditions']['showTrash']) || !empty($queryString['conditions']['showTrash']) && $queryString['conditions']['showTrash'] == 0) ? 'checked' : ''; ?>
		>
		Hide deleted users
	</label> 
	<label class="radio inline"> 
		<input 
			type="radio" 
			name="conditions[showTrash]" 
			value="1"
			<?php echo (!empty($queryString['conditions']['showTrash']) && $queryString['conditions']['showTrash'] == 1) ? 'checked' : ''; ?>
		>
		Show all users
	</label>
	&nbsp;
	<?php echo $this->Form->button('<i class="icon-search icon-white"></i>Search', array(
			'class' => ' btn btn-primary', 
			'div' => false
	))?>
	<?php echo $this->Html->link('<i class="icon-user icon-white"></i>New User', 
			array('action' => 'add', 'admin' => true), 
			array(
				'class' => 'btn btn-primary pull-right', 
				'escape' => false
	))?>
	
<?php echo $this->Form->end();?>
<table class="table table-striped">
	<thead>
		<tr>
			<th><?php echo $this->Paginator->sort(__('#'), 'id')?></th>
			<th>Username</th>
			<th><?php echo $this->Paginator->sort(__('Role'), 'role')?></th>
			<th>Email</th>
			<th><?php echo $this->Paginator->sort(__('Status'), 'status')?></th>
			<th>Others</th>
		</tr>
	</thead>
	<tbody>
		<?php foreach ($users as $user):?>
			<tr class="<?php echo ($user['User']['is_deleted']) ? 'deleted' : '' ?>">
				<td><?php echo $user['User']['id']?></td>
				<td><?php echo $user['User']['username']?></td>
				<td>
					<?php
						$roles = Configure::read('role'); 
						echo $roles[$user['User']['role']]
					?>
				</td>
				<td><?php echo $user['User']['email']?></td>
				<td><?php
						$deleteStatus = Configure::read('deleteStatus'); 
						echo $deleteStatus[$user['User']['is_deleted']]
					?>
				</td>
				<td>
					<?php if ($user['User']['is_deleted']):?>
						<?php echo $this->Html->link('Recover', array('action' => 'recover', 'admin' => true, $user['User']['id']), array('class' => 'btn'))?>
					<?php else:?>
						<?php echo $this->Html->link('Delete', array('action' => 'delete', 'admin' => true, $user['User']['id']), array('class' => 'btn'))?>
						&nbsp;
						<?php echo $this->Html->link('Edit', array('action' => 'edit', 'admin' => true, $user['User']['id']), array('class' => 'btn'))?>
					<?php endif;?>
				</td>
			</tr>
		<?php endforeach;?>
	</tbody>
</table>
<p>
	<?php
		echo $this->Paginator->counter(array(
			'format' => 'Page %page% of %pages%, showing %current% records out of %count% total.'
		)); 
	?>	
</p>
<?php if ($this->params['paging']['User']['pageCount'] > 1):?>
	<div class="btn-group">
		<span class="btn"><?php echo $this->Paginator->prev(__('previous '), array(), null);?></span>
		<span class="btn"><?php echo $this->Paginator->numbers(array('separator' => '-'));?></span>
		<span class="btn"><?php echo $this->Paginator->next(__(' next'), array(), null); ?></span>
	</div>
<?php endif;?>
